package com.yogee.topseller.fragment.zhoubian;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yogee.topseller.R;
import com.yogee.topseller.activity.ProductDetailsActivity;
import com.yogee.topseller.activity.ZhoubianActivity;
import com.yogee.topseller.adapter.FengxianAdapter;
import com.yogee.topseller.adapter.JigouAdapter;
import com.yogee.topseller.bean.FengxianBean;
import com.yogee.topseller.bean.JigouBean;
import com.yogee.topseller.bean.ProductInfoBean;
import com.yogee.topseller.fragment.productdetail.BaseFragment;
import com.yogee.topseller.utils.Constants;
import com.yogee.topseller.utils.LogUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 风险
 * Created by zwj on 2017/12/7.
 */

public class FengxianFragment extends BaseFragment implements ZhoubianActivity.UpdateListener{

    @BindView(R.id.rv_fengxian)
    RecyclerView rv_fengxian;

    FengxianAdapter fengxianAdapter;
    List<FengxianBean> list1 = new ArrayList<>();
    Unbinder unbinder1;
    private int isMj = 0;
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_fengxian;
    }


    @Override
    protected void initView() {
        ((ZhoubianActivity)getActivity()).setListener1(this);

        list1.clear();
        FengxianBean fengxianBean1 = new FengxianBean();
        fengxianBean1.setTitle("企业风险");
        List<FengxianBean.Btn> btnList = new ArrayList<>();
        btnList.add(new FengxianBean.Btn(Constants.EyeCheck_XZRF_TYPE,"行政处罚",0,R.drawable.xzcf));
        btnList.add(new FengxianBean.Btn(Constants.EyeCheck_YZWF_TYPE,"严重违法",0,R.drawable.yzwf));
        btnList.add(new FengxianBean.Btn(Constants.EyeCheck_GQCZ_TYPE,"股权出质",0,R.drawable.gqcz));
        btnList.add(new FengxianBean.Btn(Constants.EyeCheck_GBBD_TYPE,"股本变动",0,R.drawable.gbbd));
        btnList.add(new FengxianBean.Btn(Constants.EyeCheck_QYFX_TYPE,"企业风险",0,R.drawable.qyfx));
        fengxianBean1.setList(btnList);
        list1.add(fengxianBean1);

        FengxianBean fengxianBean2 = new FengxianBean();
        fengxianBean2.setTitle("经营风险");
        List<FengxianBean.Btn> btnList1= new ArrayList<>();
        btnList1.add(new FengxianBean.Btn(Constants.EyeCheck_JYYC_TYPE,"经营异常",0,R.drawable.jyyc));
        btnList1.add(new FengxianBean.Btn(Constants.EyeCheck_DCDY_TYPE,"动产抵押",0,R.drawable.dcdy));
        fengxianBean2.setList(btnList1);
        list1.add(fengxianBean2);

        FengxianBean fengxianBean3 = new FengxianBean();
        fengxianBean3.setTitle("个人风险");
        List<FengxianBean.Btn> btnList2= new ArrayList<>();
        btnList2.add(new FengxianBean.Btn(Constants.EyeCheck_SXR_TYPE,"失信人",0,R.drawable.sxr));
        btnList2.add(new FengxianBean.Btn(Constants.EyeCheck_BZXR_TYPE,"被执行人",0,R.drawable.bzxr));
        btnList2.add(new FengxianBean.Btn(Constants.EyeCheck_RFX_TYPE,"个人风险",0,R.drawable.grfx));
        fengxianBean3.setList(btnList2);
        list1.add(fengxianBean3);

        FengxianBean fengxianBean4 = new FengxianBean();
        fengxianBean4.setTitle("企业情况");
        List<FengxianBean.Btn> btnList4= new ArrayList<>();
        btnList4.add(new FengxianBean.Btn(Constants.EyeCheck_GBJG_TYPE,"股本结构",0,R.drawable.gbjg));
        btnList4.add(new FengxianBean.Btn(Constants.EyeCheck_GPHQ_TYPE,"股票行情",0,R.drawable.gphq));
        btnList4.add(new FengxianBean.Btn(Constants.EyeCheck_QYJE_TYPE,"股票简介",0,R.drawable.gpjj));
        btnList4.add(new FengxianBean.Btn(Constants.EyeCheck_GPFH_TYPE,"股票分红",0,R.drawable.gpfh));
        btnList4.add(new FengxianBean.Btn(Constants.EyeCheck_ZJXX_TYPE,"债券信息",0,R.drawable.zqxx));
        fengxianBean4.setList(btnList4);
        list1.add(fengxianBean4);


        rv_fengxian.setLayoutManager(new LinearLayoutManager(getActivity()));
        fengxianAdapter = new FengxianAdapter(getActivity());
        rv_fengxian.setAdapter(fengxianAdapter);
        fengxianAdapter.addData(list1);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder1 = ButterKnife.bind(this, rootView);

        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder1.unbind();
    }

    @Override
    public String getTitle() {
        return "机构相关";
    }


    @Override
    public void getCurrentPos(JigouBean.Company company) {
        LogUtils.e("sfz","风险:"+company.getName());
    }
}
